﻿//==================================================================
// Copyright (C) 2011  BPM
// 作 者：朱云
// 日 期：2011/12/21
// 描 述：表单用户控件
// 版 本：1.00
// 
// 修改历史纪录
// 版 本  修改时间      修改人            修改内容     
//    
//==================================================================
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HF.BaseWebCtrlLib;
using System.Data;
using HF.WorkFlow.Const;
using HF.Business.Finance;
using HF.Business.Common;
using HF.BaseWebCtrlLib;
using HF.Framework.DataClientDBAgent;
using HF.Framework.SqlDataContract;
using HF.Business.CrmTeachSumup;
using HF.Business.OA;

public partial class Modules_FWOA_Fwoaflow : BaseUserControl
{
    DataTable UserflowTable;
    string SnEvectionDet = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        base.Page_Load();
        SnEvectionDet = WorkflowInsId;//
        if (!IsPostBack)
        {
            initData();

        }
        UserflowTable = (DataTable)Session[SnEvectionDet];
    }

    public void initData()
    {
        DataTable OAcostDatable = OA_Cost.GetOA_CostTable(WorkflowInsId);
        if (OAcostDatable.Rows.Count > 0 && OAcostDatable != null)
        {
            OA_Cost oacost = new OA_Cost();
            oacost.GetOA_CostInfo(WorkflowInsId);
            lblflow.Text = oacost.Code;
            lbluser.Text = oacost.Name;
            ddltype.Text = oacost.typeName;
            txtmoney.Text = oacost.Resmoney.ToString();
            ddlmoneytype.Text = oacost.Lendmoney;
            txtusermoney.Text = oacost.Userlendmoney.ToString();
            UserflowTable = EvectionDet.Getfin_EvectionDetTable(WorkflowInsId);
        }
        else
        {
            string billType = "FCCB";
            lblflow.Text = billType + BusinessComm.GetBillCode(billType);
            lbldata.Text = DateTime.Now.ToString();
            lbluser.Text = UserName;
            lblDept.Text = archCaption;
            ClientDBAgent agent = new ClientDBAgent();
            UserflowTable = agent.GetBlankTable("fin_EvectionDet");
        }
        Session.Add(SnEvectionDet, UserflowTable);

    }
    public override void SaveUserControl(bool IsDraft)
    {
        base.SaveUserControl(IsDraft);
        OA_Cost oacost = new OA_Cost();
        oacost.Code = lblflow.Text;
        oacost.Name = lbluser.Text;
        oacost.typeName = ddltype.SelectedValue.Trim();
        oacost.Resmoney = Convert.ToInt32(txtmoney.Text);
        oacost.Lendmoney = ddlmoneytype.SelectedValue.Trim();
        oacost.Userlendmoney = Convert.ToInt32(txtusermoney.Text);
        oacost.WorkflowId = WorkflowId;
        oacost.WorkflowInsId = WorkflowInsId;
        oacost.WorktaskId = WorktaskId;
        oacost.WorktaskInsId = WorktaskInsId;
        oacost.Insert(oacost);
        //DataTable edt = Userflow.GetCrmTeachSumupTable(WorkflowInsId);

        //if (edt != null && edt.Rows.Count > 0)//检查是否有数据。
        //    //oacost.Update();
        //else
    }
}